package com.panshi.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panshi.entity.AppDynamicT;
import com.panshi.service.impl.AppDynamicTServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 动态表 前端控制器
 * </p>
 *
 * @author xhlMr
 * @since 2020-08-20
 */
@RestController
public class AppDynamicTController {

    @Autowired
    private AppDynamicTServiceImpl appDynamicTService;

    @ApiOperation("用户动态表 按用户id查询 分页")
    @GetMapping("/app-dynamic-t/getDynamic")
    public List<AppDynamicT> getDynamic(@PathVariable int userId, @PathVariable int page){
        if(page<1){
            page=1;
        }
        // 查询这个分类下的所有问题，获取查询的数据信息
        Page<AppDynamicT> pageParam = new Page<>(page, 3);
        QueryWrapper<AppDynamicT> w = new QueryWrapper<>();
        w.eq("user_id",userId);
        w.eq("msg_type","1");
        w.eq("is_remove","n");
        appDynamicTService.page(pageParam,w);

        List<AppDynamicT> userPageAll = pageParam.getRecords();
        return userPageAll;
    }
}

